package server;

import util.Logger;
import dataContracts.Command;

class EqualityHandler implements Runnable {
	ClientConnection client;
	ServerProgram server;
	String commandText;
	
	EqualityHandler(ClientConnection client, ServerProgram server, String commandText) {
		this.server = server;
		this.client = client;
		this.commandText = commandText;
	}
	
	@Override
	public void run() {
		//TODO: how to avoid reloading the directory contents each time?
		server.directory.loadFiles();
		String checksumProvided = commandText,
				serverChecksum = server.directory.getChecksum();
		client.command(Command.Type.IsEqual, (checksumProvided.equalsIgnoreCase(serverChecksum)) ? "1" : "0");
	}
}